package com.atguigu.tingshu.search.consumer;

import org.apache.kafka.clients.consumer.ConsumerRecord;
import org.springframework.kafka.annotation.KafkaListener;
import org.springframework.stereotype.Component;

/****
 * 监听kafka的用户行为消息
 */
@Component
public class RankMessageConsumer {

    /***
     * 用户行为统计消费者
     * @param record
     */
    @KafkaListener(topics = "rank_topic")
    public void rankMessageConsumer(ConsumerRecord<String, String> record){
        //获取消息的key
        String key = record.key();
        //获取消息的内容
        String value = record.value();
        System.out.println("-------------用户行为收到消息key:" + key);
        System.out.println("-------------用户行为收到消息value:" + value);
    }
}
